<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Schema;

use App\Model\Area;
use Hyperf\Swagger\Annotation\Property;
use Hyperf\Swagger\Annotation\Schema;
use JsonSerializable;

#[Schema(title: '小区详情')]
class AreaSchema implements JsonSerializable
{
    #[Property(property: 'id', title: '', type: 'int')]
    public ?int $id;

    #[Property(property: 'area_name', title: '小区名称', type: 'string')]
    public ?string $areaName;

    #[Property(property: 'area_type', title: '物业类型', type: 'string')]
    public ?string $areaType;

    #[Property(property: 'finish_time', title: '竣工时间', type: 'mixed')]
    public mixed $finishTime;

    #[Property(property: 'limit_year', title: '产权年限', type: 'string')]
    public ?string $limitYear;

    #[Property(property: 'build_type', title: '建筑类型', type: 'string')]
    public ?string $buildType;

    #[Property(property: 'area_builder', title: '开发商', type: 'string')]
    public ?string $areaBuilder;

    #[Property(property: 'area_address', title: '小区地址', type: 'string')]
    public ?string $areaAddress;

    #[Property(property: 'area_images', title: '小区图片', type: 'string')]
    public ?string $areaImages;

    #[Property(property: 'created_at', title: '', type: 'mixed')]
    public mixed $createdAt;

    #[Property(property: 'updated_at', title: '', type: 'mixed')]
    public mixed $updatedAt;

    public function __construct(Area $model)
    {
        $this->id = $model->id;
        $this->areaName = $model->area_name;
        $this->areaType = $model->area_type;
        $this->finishTime = $model->finish_time;
        $this->limitYear = $model->limit_year;
        $this->buildType = $model->build_type;
        $this->areaBuilder = $model->area_builder;
        $this->areaAddress = $model->area_address;
        $this->areaImages = $model->area_images;
        $this->createdAt = $model->created_at;
        $this->updatedAt = $model->updated_at;
    }

    public function jsonSerialize(): mixed
    {
        return ['id' => $this->id, 'area_name' => $this->areaName, 'area_type' => $this->areaType, 'finish_time' => $this->finishTime, 'limit_year' => $this->limitYear, 'build_type' => $this->buildType, 'area_builder' => $this->areaBuilder, 'area_address' => $this->areaAddress, 'area_images' => $this->areaImages, 'created_at' => $this->createdAt, 'updated_at' => $this->updatedAt];
    }
}
